/*
 * Package il.ac.biu.cs.grossmm.impl.server
 * File ServiceListener.java
 * 
 * This is a part of presence service framework API. 
 * See javadoc for more information.
 *  
 * Copyright (C) 2006 Grossmann Mark
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package il.ac.biu.cs.grossmm.api.server;

/**
 * A loader which implements this interface which receive service events.
 * 
 * @see Loader
 */
public interface ServiceListener {
	/**
	 * Invoked when service is required to start, but before it has started
	 * 
	 * @param sm
	 *            service manager for the specified service
	 * @param service
	 *            the service which caused this event
	 * @throws Exception
	 *             if thrown, the service is not started. Note that this may
	 *             cause cascading termination of services depending on this
	 *             servce
	 */
	void beforeStart(ServiceManager sm, Service service) throws Exception;

	/**
	 * Invoked immediately after a service has started
	 * 
	 * @param sm
	 *            service manager for the specified service
	 * @param service
	 *            the service which caused this event
	 */            
	void afterStart(ServiceManager sm, Service service);

	/**
	 * Invoked when service is required to stop, but is still running
	 * 
	 * @param sm
	 *            service manager for the specified service
	 * @param service
	 *            the service which caused this event
	 */            
	void beforeStop(ServiceManager sm, Service service);

	
	/**
	 * Invoked immediately after a service has stopped
	 * 
	 * @param sm
	 *            service manager for the specified service
	 * @param service
	 *            the service which caused this event
	 */ 
	void afterStop(ServiceManager sm, Service service);
}
